package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.Link;
import com.sun.hunk.hibernate.domain.LinkTree;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "link")

public class LinkImpl implements Link {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "desc")
    private String desc;
    @Column(name = "program")
    private String program;
    @Column(name = "item_created_on")
    @Temporal(TemporalType.TIMESTAMP)
    private Date itemCreatedOn;
    @OneToMany(mappedBy = "child",targetEntity=LinkTreeImpl.class)
    private Set<LinkTree> parents;
    @OneToMany(mappedBy = "parent",targetEntity=LinkTreeImpl.class)
    private Set<LinkTree> childs;

    public LinkImpl() {
    }

    public LinkImpl(Long id) {
        this.id = id;
    }

    public LinkImpl(Long id, String desc) {
        this.id = id;
        this.desc = desc;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getProgram() {
        return program;
    }

    public void setProgram(String program) {
        this.program = program;
    }

    public Date getLinkCreatedOn() {
        return itemCreatedOn;
    }

    public void setLinkCreatedOn(Date itemCreatedOn) {
        this.itemCreatedOn = itemCreatedOn;
    }

    public Set<LinkTree> getChilds() {
        return childs;
    }

    public void setChilds(Set<LinkTree> childs) {
        this.childs = childs;
    }

    public Set<LinkTree> getParents() {
        return parents;
    }

    public void setParents(Set<LinkTree> parents) {
        this.parents = parents;
    }
    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof LinkImpl)) {
            return false;
        }
        LinkImpl other = (LinkImpl) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.cong.logiware.hibernate.domain.Link[id=" + id + "]";
    }

}
